package com.NHL.modules.map
{
	import com.NHL.modules.core.BasicContainer;
	import com.NHL.modules.map.vo.MapVo;
	import com.NHL.modules.mc.Role;
	import com.NHL.single.GlobalModel;
	import com.NHL.utils.MapUtil;
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	import flashx.textLayout.elements.SpecialCharacterElement;
	
	public class MapScence extends BasicContainer
	{
		private var _map:Sprite;
		
		private var _self:Role;
		
		private var _globalModel:GlobalModel;		
		
		
		private var _mapVo:MapVo;
		public function MapScence()
		{
			super();
			_globalModel = GlobalModel.getInstance();
			initSelf();
		}
		
		override protected function initConpenent():void
		{
			
		}
		
		private function initSelf():void
		{
			_self = new Role();
			
			_globalModel.self = _self;
		}
		
		override protected function addEvent():void
		{
			addEventListener(MouseEvent.MOUSE_DOWN,onMapDown,false,0,true);
			
		}
		
		private function onMapDown(evt:MouseEvent):void
		{
			var point:Point = new Point(evt.stageX,evt.stageY);
			point = MapUtil.TranMapToMouse(point);
			point = check(point)
			_self
			//_s
		}
		
	
		
		private function check(point:Point):Point
		{
			var rect:Rectangle = _mapVo.rectangle;
			point.y = point.y < rect.y? rect.y:point.y;
			point.y = point.y > (rect.y + rect.width)?(rect.y + rect.width):point.y;
			point.x = point.x < rect.x? rect.x: point.x;
			point.x = point.x < rect.right? rect.right:point.x;
			return point;
			
		}
	}
}